package app

import (
	"cr.org/middleware"
	"cr.org/modules/api"
	"github.com/gin-gonic/gin"
	"net/http"
)

func setupRoutes() *gin.Engine {
	r := gin.New()
	//gin.SetMode(gin.ReleaseMode) //使用 release 模式运行，

	r.Use(gin.Recovery(),
		middleware.LoggerError())
	publicGroup := r.Group("")
	{
		// 健康监测
		publicGroup.GET("/health", func(c *gin.Context) {
			c.JSON(200, "ok")
		})
		publicGroup.POST("upload", api.FileApi.FileUpload)
		publicGroup.POST("login", api.UserApi.Login)
	}

	privateGroup := r.Group("").Use(middleware.GinAuthorizationMiddleAware(),
		middleware.JWTAuth(""))
	{
		privateGroup.GET("logout", api.UserApi.Logout)
		privateGroup.GET("GetAiDrawTop5", api.OtherApi.GetAiDrawTop5)
		privateGroup.GET("AiDrawPage", api.OtherApi.AiDrawPage)
		privateGroup.GET("AiModelsPage", api.OtherApi.AiModelsPage)
		privateGroup.POST("SaveAiDraw", api.OtherApi.SaveAiDraw)
		privateGroup.POST("CheckThumbsUpStatus", api.OtherApi.CheckThumbsUpStatus)
		privateGroup.POST("UpdateThumbsUpAddOne", api.OtherApi.UpdateThumbsUpAddOne)
		privateGroup.POST("SaveAiModels", api.OtherApi.SaveAiModels)
		privateGroup.POST("GetAiModelDetail", api.OtherApi.GetAiModelDetail)

		privateGroup.POST("FileUpload", api.FileApi.FileUpload)
		privateGroup.POST("MultipartFileUpload", api.FileApi.MultipartFileUpload)

		privateGroup.POST("AddUser", api.UserApi.AddUser)

	}

	return r
}

// todo 还没想好的接口占位符
func todo(ctx *gin.Context) {
	ctx.JSON(http.StatusCreated, "todo")
}
